package Thread;

//getState(获取线程的状态(6种))
public class Demo16 {
    public static void main(String[] args) throws InterruptedException {
        Thread mainThread = Thread.currentThread();

        Thread t = new Thread(()->{
            while(true){
                System.out.println("main state=" + mainThread.getState());
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        System.out.println(t.getState());

        t.start();

        //由于t线程是持续while循环,因此join不会返回
        //此时观察主线程的状态就能看到WAITING
        t.join();

        Thread.sleep(500);

        System.out.println(t.getState());
    }
}
